home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / utilities / shell / zshell20.lha / ZShell20 / ZSH.S < prev    next >
Encoding:
Text File  |  1994-07-02  |  15.2 KB  |  725 lines

  1.  
  2. ****************************************************
  3. ********   ZSHELL (C) 1990,91 Paul Hayter   ********
  4. ********  updated to V2.0 by Martin Gierich ********
  5. ********     ZShell-Starter (ZSH)        ********
  6. ****************************************************
  7.  
  8. ***        TABSIZE = 8 Chars         ***
  9. ***     Local Labels named .A to .Z         ***
  10.  
  11. FIB            equ    260            ;FileInfoBlock
  12. ACCESS_READ        equ    -2
  13. ACCESS_WRITE        equ    -1
  14. MODE_READWRITE        equ    1004
  15. MODE_OLDFILE        equ    1005
  16. MODE_NEWFILE        equ    1006
  17.  
  18. * DOS LIBRARY
  19. dl_A2            equ    42
  20.  
  21. SIGBREAKB_CTRL_C    equ    $0C
  22. SIGBREAKB_CTRL_D    equ    $0D
  23.     
  24. * FILE INFO BLOCK
  25. fib_DiskKey        equ  $0000
  26. fib_DirEntryType    equ  $0004
  27. fib_FileName        equ  $0008
  28. fib_Protection        equ  $0074
  29. fib_EntryType        equ  $0078
  30. fib_Size        equ  $007c
  31. fib_NumBlocks        equ  $0080
  32. fib_Date        equ  $0084
  33. fib_Comment        equ  $0090
  34. fib_Reserved        equ  $00e0
  35.  
  36. * INFO DATA STRUCTURE
  37. id_NumSoftErrors    equ    0
  38. id_UnitNumber        equ    4
  39. id_DiskState        equ    8
  40. id_NumBlocks        equ    12
  41. id_NumBlocksUsed    equ    16
  42. id_BytesPerBlock    equ    20
  43. id_DiskType        equ    24
  44. id_VolumeNode        equ    28
  45. id_InUse        equ    32
  46.  
  47. * PROCESS
  48. pr_MsgPort        equ    92
  49. pr_SegList        equ    128
  50. pr_StackSize        equ    132
  51. pr_GlobVec        equ    136
  52. pr_TaskNum        equ    140
  53. pr_StackBase        equ    144
  54. pr_Result2        equ    148
  55. pr_CurrentDir        equ    152
  56. pr_CIS            equ    156
  57. pr_COS            equ    160
  58. pr_ConsoleTask        equ    164
  59. pr_FileSystemTask    equ    168
  60. pr_CLI            equ    172
  61. pr_ReturnAddr        equ    176
  62. pr_PktWait        equ    180
  63. pr_WindowPtr        equ    184
  64.  
  65. * COMMAND LINE INTERFACE
  66. cli_Result        equ    0
  67. cli_SetName        equ    4
  68. cli_CommandDir        equ    8
  69. cli_ReturnCode        equ    12
  70. cli_CommandName        equ    16
  71. cli_FailLevel        equ    20
  72. cli_Prompt        equ    24
  73. cli_StandardInput    equ    28
  74. cli_CurrentInput    equ    32
  75. cli_CommandFile        equ    36
  76. cli_Interactive        equ    40
  77. cli_Background        equ    44
  78. cli_CurrentOutput    equ    48
  79. cli_DefaultStack    equ    52
  80. cli_StandardOutput    equ    56
  81. cli_Module        equ    60
  82.  
  83. * FILE HANDLE
  84. fh_Link            equ    0
  85. fh_Port            equ    4
  86. fh_Type            equ    8
  87. fh_Buf            equ    12
  88. fh_Pos            equ    16
  89. fh_End            equ    20
  90.  
  91. * FILE LOCK
  92. fl_Link            equ    0
  93. fl_Key            equ    4
  94. fl_Access        equ    8
  95. fl_Task            equ    12
  96. fl_Volume        equ    16
  97.  
  98. * DATESTAMP
  99. ds_Days            equ    0
  100. ds_Minute        equ    4
  101. ds_Tick            equ    8
  102.  
  103. RETURN_OK        EQU  0
  104. RETURN_WARN        EQU  5
  105. RETURN_ERROR        EQU  10
  106. RETURN_FAIL        EQU  20
  107.  
  108. *Assign Stuff
  109. dl_Root        equ    34    APTR
  110. rn_Info        equ    24    BPTR
  111. di_DevInfo    equ    4    BPTR
  112. di_NetHand    equ    16    BPTR
  113. dvi_Next    equ    0    BPTR
  114. dvi_Type    equ    4    LONG
  115. dvi_Task    equ    8    APTR
  116. dvi_Lock    equ    12    BPTR
  117. dvi_Handler    equ    16
  118. dvi_StackSize    equ    20
  119. dvi_Priority    equ    24
  120. dvi_Startup    equ    28
  121. dvi_SegList    equ    32
  122. dvi_GlobVec    equ    36
  123. dvi_Name    equ    40    BSTR
  124. dt_device    equ    0    <-- contents of dvi_Type
  125. dt_dir        equ    1
  126. dt_volume    equ    2
  127.  
  128. *Resident Stuff
  129. resi_link    equ    0    ;BPTR
  130. resi_usecount    equ    4    ;LONG
  131. resi_seglist    equ    8    ;BPTR
  132. resi_name    equ    12    ;BSTR
  133. resi_length    equ    4+4+4
  134.  
  135. *Icon Lib Stuff
  136. sm_Process    equ    $14
  137. sm_Segment    equ    $18
  138. sm_NumArgs    equ    $1c
  139. sm_ToolWindow    equ    $20
  140. sm_ArgList    equ    $24
  141. wa_Lock        equ    0
  142. wa_Name        equ    4
  143. do_Magic    equ    0    ;must be $e310
  144. do_Type        equ    $30
  145. do_ToolTypes    equ    $36
  146. do_ToolWindow    equ    $46
  147. do_StackSize    equ    $4a
  148.  
  149. * AVAIL STUFF
  150. MEMF_PUBLIC        equ 1
  151. MEMF_CHIP        equ 2
  152. MEMF_FAST        equ 4
  153. MEMF_CLEAR        equ $10000
  154. MEMF_LARGEST        equ $20000
  155.  
  156. * ACTIONS
  157. ACTION_SCREEN_MODE    EQU    994
  158. ACTION_INHIBIT        EQU    31
  159. ACTION_MORE_CACHE    EQU    18
  160. ACTION_RENAME_DISK    EQU    9
  161. ACTION_DIE        EQU    5
  162. ACTION_DISK_CHANGE    EQU    33
  163. ACTION_SET_DATE        EQU    34
  164. ACTION_DISK_INFO    EQU    25
  165. ACTION_WRITE_PROTECT    EQU    1023
  166.  
  167. dp_Link        EQU  $00   ;DosPacket Structure
  168. dp_Port        EQU  $04
  169. dp_Type        EQU  $08
  170. dp_Arg1        EQU  $14
  171. dp_SIZEOF    EQU  $30
  172.  
  173. sp_Msg        EQU  $00   ;StandardPacket Structure
  174. sp_Pkt        EQU  $14
  175. sp_SIZEOF    EQU  $44
  176.  
  177. LH_TAIL        EQU  $04
  178.  
  179. LN_PRED        EQU  $04
  180. LN_TYPE        EQU  $08
  181. LN_NAME        EQU  $0A
  182.  
  183. NT_MSGPORT    EQU  4
  184.  
  185. MP_FLAGS    EQU  $0E   ;Message Port Structure
  186. MP_SIGBIT    EQU  $0F   ;Signal bit number
  187. MP_SIGTASK    EQU  $10   ;Task to be signalled
  188. MP_MSGLIST    EQU  $14   ;Message linked list
  189. MP_SIZE        EQU  $22
  190.  
  191. mn_ReplyPort    equ    14
  192. mn_Length    equ    18
  193.  
  194. PA_SIGNAL    EQU  0       ;PutAction messages
  195.  
  196.     
  197. * LIBRARY CALLS
  198. * EXEC
  199. _LVOOpenLibrary        equ    -552
  200. _LVOCloseLibrary    equ    -414
  201. _LVOSetFunction        equ    -420
  202. _LVOAllocMem        equ    -198
  203. _LVOFreeMem        equ    -210
  204. _LVORawDoFmt        equ    -522
  205. _LVORawMayGetChar    equ    -510
  206. _LVOFindTask        equ    -294
  207. _LVOAddTask        equ    -282
  208. _LVOForbid        equ    -132
  209. _LVOPermit        equ    -138
  210. _LVOAvailMem        equ    -216
  211. _LVOPutMsg        equ    -366
  212. _LVOGetMsg        equ    -372
  213. _LVOReplyMsg        equ    -378
  214. _LVOWaitPort        equ    -384
  215. _LVOSetSignal        equ    -306
  216. _LVOAllocSignal        equ    -330
  217. _LVOFreeSignal        equ    -336
  218. _LVOOpenDev        equ    -444
  219. _LVOCloseDev        equ    -450
  220. _LVODoIO        equ    -456
  221.  
  222. * DOS
  223. _LVOSetProtection    equ    -186
  224. _LVOOutput        equ    -60
  225. _LVOWrite        equ    -48
  226. _LVOLock        equ    -84
  227. _LVOUnLock        equ    -90
  228. _LVODupLock        equ    -96
  229. _LVOExamine        equ    -102
  230. _LVOExNext        equ    -108
  231. _LVOOpen        equ    -30
  232. _LVOClose        equ    -36
  233. _LVORead        equ    -42
  234. _LVOInput        equ    -54
  235. _LVODeleteFile        equ    -72
  236. _LVORename        equ    -78
  237. _LVOCreateDir        equ    -120
  238. _LVOCurrentDir        equ    -126
  239. _LVOIoErr        equ    -132
  240. _LVOParentDir        equ    -210
  241. _LVOLoadSeg        equ    -150
  242. _LVOUnLoadSeg        equ    -156
  243. _LVOCreateProc        equ    -138
  244. _LVOInfo        equ    -114
  245. _LVODateStamp        equ    -192
  246. _LVOSeek        equ    -66
  247. _LVODeviceProc        equ    -174
  248. _LVODelay        equ    -198
  249. _LVOSetComment        equ    -180
  250. _LVOIsInteractive    equ    -216
  251.  
  252. *Intuition
  253. _LVOPrintIText        equ    -216
  254. _LVODisplayBeep        equ    -96
  255.  
  256. *Icon
  257. _LVOGetDiskObject    equ    -78
  258. _LVOFreeDiskObject    equ    -90
  259. _LVOFindToolType    equ    -96
  260. _LVOMatchToolValue    equ    -102
  261.  
  262.  
  263. * NEED THESE 2 MACROS FOR A68K ASSEMBLER
  264. ;blo    macro
  265. ;    bcs \1
  266. ;    endm
  267.     
  268. ;bhs    macro
  269. ;    bcc \1
  270. ;    endm
  271.  
  272. *SYSTEM0 stuff!!!!!!!!!!
  273. REG_SysBase    equr a6
  274.  
  275. callsys    macro
  276.     jsr _LVO\1(REG_SysBase)
  277.     endm
  278.  
  279. * parameter offsets & stack
  280. ;SAVED_REGS    reg    a2-a6/d2-d3
  281. DELTA        equ    7*4
  282. ARG_NAME    equ    4+DELTA
  283. ARG_SEGLIST    equ    8+DELTA
  284. ARG_ARGS    equ    12+DELTA
  285.  
  286. * additional return codes
  287. NO_CLI        equ    -1
  288. NO_MEM        equ    -2
  289.  
  290. * local constants
  291. MAXBSTR        equ    255
  292. LF        equ    10
  293.  
  294. * register usage
  295. REG_Result    equr    d3
  296. REG_Process    equr    a2      ;may not be A4, see below!
  297. REG_CLI        equr    a3
  298. REG_CIS        equr    a4      ;may not be A3, see below!
  299. REG_PrevStack    equr    a1    ;V2.0 changed from a5 to a1
  300.  
  301. * local stack frame
  302. * STRUCTURE      StackFrame,0
  303. sf_CommandName    equ    0
  304. sf_CommandArgs    equ    MAXBSTR+1        ;BSTR, length byte!
  305. sf_PrevStack    equ    sf_CommandArgs+MAXBSTR+1        ;not a BSTR, LF-terminated!
  306. sf_SaveReturnAddr    equ    sf_PrevStack+4
  307. sf_SaveModule    equ    sf_SaveReturnAddr+4
  308. sf_SaveCommandName    equ    sf_SaveModule+4
  309. sf_StackBase    equ    sf_SaveCommandName+4
  310. sf_StackSize    equ    sf_StackBase+4
  311. sf_PushSize    equ    sf_StackSize+4
  312. sf_Process    equ    sf_PushSize+4
  313. sf_CLI        equ    sf_Process+4
  314. sf_CIS        equ    sf_CLI+4
  315. sf_SCB_Buf    equ    sf_CIS+4
  316. sf_SCB_Pos    equ    sf_SCB_Buf+4
  317. sf_SCB_End    equ    sf_SCB_Pos+4
  318. sf_Membase    equ    sf_SCB_End+4
  319. sf_SIZEOF    equ    sf_Membase+4
  320.  
  321. *Constants (only LONGS!)
  322. SHELLINE_SIZE    equ    256    V1.30
  323. CLIBUF_SIZE    equ    256
  324. NEWPRINTSIZE    equ    200
  325. PATH_SIZE    equ    256    V1.30
  326. HISTORY_SIZE    equ    1024    MUST BE POWER OF 2
  327. SEARCH_STRING_SIZE    equ    60
  328. DEST_LABEL_SIZE    equ    60
  329.  
  330.  
  331. * THE GENERAL MEMORY BLOCK (LONGS!)
  332. blockbase    equ    0    ;the fib or info goes here
  333. sp_node        equ    blockbase+260    ;DOSpacket
  334. sp_reply    equ    sp_node+14
  335. sp_length    equ    sp_reply+4
  336. ;sp_ptr        equ    ;sp_ptr+4
  337. sp_link        equ    sp_length+2
  338. sp_port        equ    sp_link+4
  339. packettype    equ    sp_port+4
  340. sp_res1        equ    packettype+4
  341. sp_res2        equ    sp_res1+4
  342. myArg1        equ    sp_res2+4
  343. myArg2        equ    myArg1+4
  344. myArg3        equ    myArg2+4
  345. myArg4        equ    myArg3+4
  346. myArg5        equ    myArg4+4
  347. myArg6        equ    myArg5+4
  348. myArg7        equ    myArg6+4
  349. packettask    equ    myArg7+4
  350. devproc        equ    packettask+4
  351. dirlock        equ    devproc+4
  352. last_failcode    equ    dirlock+4
  353. outhandle    equ    last_failcode+4    ;Handles
  354. inhandle    equ    outhandle+4
  355. EntryA0        equ    inhandle+4
  356. better_Seglist    equ    EntryA0+4
  357. parm1        equ    better_Seglist+4 ;addr of each parameter within shelline
  358. parm2        equ    parm1+4
  359. parm3        equ    parm2+4
  360. parm4        equ    parm3+4
  361. parm5        equ    parm4+4
  362. parm6        equ    parm5+4
  363. parm7        equ    parm6+4
  364. parm8        equ    parm7+4
  365. parm9        equ    parm8+4
  366. parm10        equ    parm9+4
  367. parm11        equ    parm10+4
  368. parm12        equ    parm11+4
  369. parm13        equ    parm12+4
  370. parm14        equ    parm13+4
  371. parm15        equ    parm14+4
  372. endofparms    equ    parm15+4+4*10    10 extra parms
  373.  
  374. shelline    equ    endofparms+4    for NULL-end        
  375. endofshelline    equ    shelline+SHELLINE_SIZE
  376.  
  377. CLIbuf        equ    endofshelline
  378. NewPrintBuffer    equ    CLIbuf+CLIBUF_SIZE
  379. errorstack    equ    NewPrintBuffer+NEWPRINTSIZE
  380. topstack    equ    errorstack+4
  381. stacksize    equ    topstack+4
  382. temp1        equ    stacksize+4
  383. temp2        equ    temp1+4
  384. temp3        equ    temp2+4
  385. temp4        equ    temp3+4
  386. tempbuf        equ    temp4+4
  387. temp2buf    equ    tempbuf+2*SHELLINE_SIZE    ;80 char temp buffer
  388. dosbase        equ    temp2buf+80
  389. intuibase    equ    dosbase+4
  390. Result2        equ    intuibase+4
  391. count_line    equ    Result2+4
  392. ignoreit    equ    count_line+4    for filenamecompletition
  393. unused_mem    equ    ignoreit+SEARCH_STRING_SIZE    for the future
  394. bordersize    equ    unused_mem+12
  395. scsize        equ    bordersize+4
  396. scaddr        equ    scsize+4
  397. scptr        equ    scaddr+4
  398. scflag        equ    scptr+4        new v1.29
  399. patharea    equ    scflag+2
  400. now        equ    patharea+PATH_SIZE
  401. nost        equ    now+4
  402. then        equ    nost+4
  403. past        equ    then+4    ;history buffer=1024 bytes
  404. thistask    equ    past+HISTORY_SIZE
  405. gather_ptr    equ    thistask+4
  406. gather        equ    gather_ptr+4 ;CSI string=40 bytes
  407. tempbytes    equ    gather+40
  408. first_set_defn    equ    tempbytes+2
  409. set_search_string    equ    first_set_defn+4
  410. line_count    equ    set_search_string+SEARCH_STRING_SIZE
  411. mem_addr    equ    line_count+2
  412. wild_flag    equ    mem_addr+4
  413. stat_mode_flag    equ    wild_flag+1
  414. wild_string    equ    stat_mode_flag+1    allow 80 chars for wildcard
  415. date_mark    equ    wild_string+80    3 lwords
  416. mem_mark    equ    date_mark+12    3 lwords chip/fast/total
  417. CD_string    equ    mem_mark+12    Allow 80 bytes.
  418. prompt_string    equ    CD_string+80    Allow 80 bytes.
  419. prompt_args    equ    prompt_string+80    Allow 40 bytes
  420. nonstdin    equ    prompt_args+40    Allow 40 bytes
  421. nonstdout    equ    nonstdin+40    Allow 40 bytes
  422. stdout        equ    nonstdout+40
  423. stdin        equ    stdout+4
  424. mult_comm_flag    equ    stdin+4
  425. next_comm_ptr    equ    mult_comm_flag+2
  426. ctrl_c_flag    equ    next_comm_ptr+4
  427. failat_level    equ    ctrl_c_flag+2    word size
  428. cd_block    equ    failat_level+2
  429. cd_volnode    equ    cd_block+4
  430. recurs_flag    equ    cd_volnode+4
  431. indent_count    equ    recurs_flag+2
  432. resi_flag    equ    indent_count+2
  433. forcediskflag    equ    resi_flag+1
  434. CLIflag        equ    forcediskflag+1
  435. WBflag        equ    CLIflag+1
  436. window_old    equ    WBflag+1
  437. wb_msg        equ    window_old+4
  438. iconbase    equ    wb_msg+4
  439. diskobj        equ    iconbase+4
  440. filesys_old    equ    diskobj+4
  441. cdir_old    equ    filesys_old+4
  442. cdback        equ    cdir_old+4
  443. ctrl_codes    equ    cdback+4    Keyboard-CTRL-Codes
  444. if_flag        equ    ctrl_codes+16
  445. if_condition_flag    equ    if_flag+1
  446. goto_flag    equ    if_condition_flag+1
  447. kickver        equ    goto_flag+1
  448. dest_label    equ    kickver+1
  449. please_close_me    equ    dest_label+DEST_LABEL_SIZE
  450. mem_offset_addr    equ    please_close_me+4
  451. io_Message    equ    mem_offset_addr+4    ;io-request (timer)
  452. io_Device    equ    io_Message+20
  453. io_Unit        equ    io_Device+4
  454. io_Command    equ    io_Unit+4
  455. io_Flags    equ    io_Command+2
  456. io_Error    equ    io_Flags+1
  457. tv_secs        equ    io_Error+1
  458. tv_micro    equ    tv_secs+4
  459. io_pad        equ    tv_micro+4    ;don't remove
  460.     
  461. stackbot    equ    io_pad+8
  462. sizeofblk    equ    stackbot
  463.  
  464.  
  465.  
  466. ********************************************
  467.  
  468. ;    SECTION    MYSHELL,CODE
  469.     
  470. ;Try to open dos then do the shell
  471. start    moveq    #-1,d7
  472.     move.l    a0,a2
  473.     move.l    4.w,a6
  474.     move.l    #sizeofblk,d0
  475.     move.l    #1+1<<16,d1        "memf_public" & clear it
  476.     jsr    _LVOAllocMem(a6)    alloc general mem block
  477.     tst.l    d0
  478.     beq    blkfail
  479.     move.l    d0,a5            A5=MEMBASE
  480.     move.l    sp,topstack(a5)
  481.     move.l    a2,EntryA0(a5)
  482.     cmp.w    #36,20(a6)        lib_Version
  483.     blo.s    .D
  484.     move.b    #2,kickver(a5)        KS2.0+
  485. .D    moveq    #0,d0
  486.     lea    intuiname(pc),a1
  487.     jsr    _LVOOpenLibrary(a6)
  488.     tst.l    d0
  489.     beq    intfail
  490.     move.l    d0,intuibase(a5)
  491.     moveq    #0,d0
  492.     lea    dosname(pc),a1
  493.     jsr    _LVOOpenLibrary(a6)
  494.     tst.l    d0
  495.     beq    dosfail
  496.     move.l    d0,dosbase(a5)
  497.     clr.w    CLIflag(a5)        delete CLI&WBflag
  498.     sub.l    a1,a1
  499.     jsr    _LVOFindTask(a6)
  500.     move.l    d0,thistask(a5)        save this task address
  501.     move.l    d0,a2
  502.     tst.l    pr_CLI(a2)
  503.     bne.s    .A
  504.     moveq    #-1,d0            WB-Start
  505.     move.w    d0,CLIflag(a5)
  506.     lea    pr_MsgPort(a2),a0
  507.     jsr    _LVOWaitPort(a6)
  508.     lea    pr_MsgPort(a2),a0
  509.     jsr    _LVOGetMsg(a6)
  510.     move.l    d0,wb_msg(a5)
  511.     beq.s    .C
  512.     move.l    d0,a0
  513.     clr.l    sm_Segment(a0)        Clear Seg-Descriptor
  514. .C    move.l    pr_StackSize(a2),stacksize(a5)
  515.     move.l    pr_SegList(a2),a0
  516.     add.l    a0,a0
  517.     add.l    a0,a0
  518.     clr.l    12(a0)            Clear SegPointer
  519.     bra.s    .B
  520. .A    move.l    pr_CLI(a2),a2        CLI-Start
  521.     add.l    a2,a2
  522.     add.l    a2,a2
  523.     move.l    cli_DefaultStack(a2),d0
  524.     asl.l    #2,d0
  525.     move.l    d0,stacksize(a5)    save stacksize
  526.     clr.l    cli_Module(a2)        do not free seglist
  527. .B    move.l    dosbase(a5),a6        A6=DOSBASE
  528. lookres    lea    ZShellName(pc),a4
  529.     bsr    search_res2
  530.     lea    start-4(pc),a1
  531.     tst.l    d0
  532.     beq.s    cresi        !beq    cresi    !
  533.     addq.l    #1,resi_usecount(a0)
  534.     lsl.l    #2,d0
  535.     cmp.l    a1,d0
  536.     beq.s    crfail        running as resident
  537.     add.l    #JumpIn-start+4,d0
  538.     move.l    d0,a0
  539.     jmp    (a0)    Jump to JumpIn, but in the resident Code
  540.  
  541. JumpIn;*move.l    a1,d1    here it arrives
  542. ;    lsr.l    #2,d1
  543. ;    jsr    _LVOUnLoadSeg(a6)    free old mem
  544. ;    bra.s    doIT
  545. cresi    lea    ZShellCom(pc),a0
  546.     move.l    a0,d1
  547.     jsr    _LVOLoadSeg(a6)
  548.     lea    ZShellName(pc),a4
  549.     move.l    d0,d3
  550.     beq.s    crerror
  551.     bsr    create_resi    make zshell resident
  552.     bne.s    crerror
  553.     bra.s    lookres
  554.  
  555. crerror    lea    console(pc),a0    output a message
  556.     move.l    a0,d1
  557.     move.l    #1005,d2
  558.     jsr    _LVOOpen(a6)    on a simple CON: window
  559.     move.l    d0,d4
  560.     beq.s    crfail
  561.     move.l    d0,d1
  562.     lea    errtx(pc),a0
  563.     move.l    a0,d2
  564.     move.l    #errtxend-errtx,d3
  565.     jsr    _LVOWrite(a6)
  566.     moveq    #120,d1
  567.     jsr    _LVODelay(a6)    wait a bit
  568.     move.l    d4,d1
  569.     jsr    _LVOClose(a6)
  570. crfail    move.l    dosbase(a5),a1    bad error occured
  571.     move.l    4.w,a6
  572.     jsr    _LVOCloseLibrary(a6)
  573. dosfail    move.l    intuibase(a5),a1
  574.     jsr    _LVOCloseLibrary(a6)
  575. intfail    move.l    wb_msg(a5),d2
  576.     move.l    a5,a1
  577.     move.l    #sizeofblk,d0
  578.     jsr    _LVOFreeMem(a6)
  579.     tst.l    d2
  580.     beq.s    .A
  581.     jsr    _LVOForbid(a6)    (what for ?)
  582.     move.l    d2,a1        WB-Message
  583.     jmp    _LVOReplyMsg(a6)    never returns !
  584. .A    moveq    #0,d0
  585.     rts
  586. blkfail    moveq    #RETURN_ERROR,d0
  587.     rts
  588.     
  589.  
  590. search_res2
  591.     bsr    resi_hand
  592.     beq.s    .D
  593.     move.l    a0,d2
  594. .A    lsl.l    #2,d0
  595.     move.l    a4,a1            string
  596.     move.l    d0,a2
  597.     lea    resi_name(a2),a0    BSTR
  598.     moveq    #0,d3
  599.     move.b    (a0)+,d3
  600.     subq.w    #1,d3
  601. .B    move.b    (a0)+,d0
  602.     move.b    (a1)+,d1
  603.     bsr    compD1D0nocase
  604.     dbne    d3,.B
  605.     bne.s    .E    not equal
  606.     tst.b    (a1)
  607.     beq.s    .C    the (null-)END
  608. .E    move.l    a2,d2
  609.     move.l    resi_link(a2),d0    get link
  610.     bne.s    .A
  611. .D    moveq    #0,d0
  612.     rts
  613. .C    move.l    resi_seglist(a2),d0    get seglist
  614.     move.l    a2,a0
  615.     rts
  616.  
  617. resi_hand    move.l    dl_Root(a6),a0
  618.     move.l    rn_Info(a0),a0
  619.     add.l    a0,a0
  620.     add.l    a0,a0
  621.     lea    di_NetHand(a0),a0    NetHand in A0
  622.     move.l    (a0),d0        Start of Resi-List in D0
  623.     rts
  624.  
  625. compD1D0nocase
  626.     cmp.b    #'a',d1
  627.     blo.s    D1_OK
  628.     cmp.b    #'z',d1
  629.     bhi.s    D1_OK
  630.     sub.b    #$20,d1
  631. D1_OK    cmp.b    #'a',d0
  632.     blo.s    D0_OK
  633.     cmp.b    #'z',d0
  634.     bhi.s    D0_OK
  635.     sub.b    #$20,d0
  636. D0_OK    cmp.b    d1,d0
  637.     rts
  638.  
  639.  
  640.  
  641.  
  642. create_resi        ;D3:SegList, A4:Name
  643.     moveq    #resi_length,d0
  644.     move.l    a4,a0
  645. .A    addq.l    #1,d0    one more for lenght-byte
  646.     tst.b    (a0)+
  647.     bne.s    .A
  648.     addq.l    #4,d0    4 more for segment-length
  649.     addq.l    #8,d0    (8 more for and'ing needed by UnLoadSeg)
  650.     moveq    #-4,d1
  651.     and.l    d1,d0
  652.     move.l    d0,d2
  653.     moveq    #1,d1
  654.     bsr    iwantmem
  655.     beq.s    resi_no_mem
  656.     addq.l    #4,d0
  657.     move.l    d0,a2        D0=addr of resi_list_node
  658.     move.l    d2,-4(a2)    save segment-length
  659.     bsr    do_forbid
  660.     bsr    resi_hand
  661.     move.l    d0,resi_link(a2)
  662.     move.l    a2,d0
  663.     lsr.l    #2,d0
  664.     move.l    d0,(a0)
  665.     moveq    #1,d0
  666.     move.l    d0,resi_usecount(a2)
  667.     move.l    d3,resi_seglist(a2)
  668.     lea    resi_name(a2),a1
  669.     move.l    a4,a0
  670.     moveq    #-1,d0
  671.     bsr    cpBSTR
  672.     bsr    do_permit
  673.     moveq    #0,d0
  674.     rts
  675. resi_no_mem
  676.     moveq    #-1,d0
  677.     rts
  678.  
  679. ******    Copy String from A0 to BSTR A1
  680. cpBSTR    movem.l    d1-d2/a0-a2,-(sp)    max. Length-2 in D0
  681.     lea    1(a1),a2
  682.     moveq    #0,d2
  683.     bra.s    .B
  684. .A    move.b    d1,(a2)+
  685.     addq.l    #1,d2
  686. .B    move.b    (a0)+,d1
  687.     dbeq    d0,.A
  688.     clr.b    (a2)    ;NULL-end it
  689.     move.b    d2,(a1)
  690.     move.l    a1,d0
  691.     lsr.l    #2,d0
  692.     movem.l    (sp)+,d1-d2/a0-a2    D0 is BPTR to the BSTR
  693.     rts
  694.  
  695. *ALLOCATE MEMORY D0=size D1=type
  696. iwantmem    movem.l d1/a0-a1,-(sp)
  697.     move.l 4.w,a6
  698.     jsr _LVOAllocMem(a6)
  699.     move.l dosbase(a5),a6
  700.     movem.l (sp)+,d1/a0-a1
  701.     tst.l    d0
  702.     rts
  703.  
  704. do_forbid    move.l    4.w,a6
  705.     jsr    _LVOForbid(a6)
  706.     move.l    dosbase(a5),a6
  707.     rts
  708. do_permit    move.l    4.w,a6
  709.     jsr    _LVOPermit(a6)
  710.     move.l    dosbase(a5),a6
  711.     rts
  712.     
  713. VersionNo    dc.b    '$VER ZSH V2.0 (06.06.94)',0
  714. ZShellCom    dc.b    'C:'
  715. ZShellName    dc.b    'ZShell',0
  716. console        dc.b    'CON:100/20/450/80/ZSH-Error',0
  717. errtx        dc.b    'Please copy "ZShell" to C: !'
  718. errtxend
  719. dosname        dc.b    'dos.library',0
  720. intuiname    dc.b    'intuition.library',0
  721.  
  722.     end
  723. ****************************************************************
  724.  
  725.